<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/12/7
  Time: 23:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册页面</title>
</head>
<body>
    <h1>用户的注册</h1>
    <form action="/user/insert" method="post">
        用户名：<input type="text" name="name" value="" id="userName">
        <input type="button" value="生成" id="shengcheng"><br />
        密码：<input type="password" name="pwd"><br />
        重新输入密码：<input type="password" name="pwd02"><br/>
        电话：<input type="text" name="phone"><br/>
        验证码：<input type="text" name="yzm" id="yzm">  <input type="button" value="获取验证码" id="yzmt">
        邮箱：<input type="text" name="email"><br />
        性别：<input type="text" name="sex"><br />
        出生日期：<input type="date" name="date"><br />
        <input type="submit" value="提交">
    </form>
</body>
<%--导入Jquery--%>
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<script>
    $(function () {
        /*
        * 生成用户姓名
        * */
        $("#shengcheng").click(function () {
            $.ajax({
                type : "post",
                url : "/user/RandomName",
                cache : true,
                async : true,
                success: function (data){
                    $("#userName").val(data);
                },
                error:function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(typeof (errorThrown));
                }
            });
        })
        /**
         * 生成短信验证码
         * */
        $("#yzmt").click(function () {
            $.ajax({
                type : "post",
                url : "/user/RandomNumber",
                cache : true,
                async : true,
                success: function (data){
                    alert(data)
                },
                error:function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(typeof (errorThrown));
                }
            });
        })


    })
</script>
</html>
